package negocio;

import java.io.Serializable;
import java.util.ArrayList;
import java.util.List;

import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.OneToMany;
import javax.persistence.Table;

@Entity
@Table(name="listasReposicion")
public class ListaReposicion implements Serializable{
	/**
	 * 
	 */
	private static final long serialVersionUID = 1L;
	
	@Id
	@GeneratedValue(strategy=GenerationType.AUTO)
	@Column(name="id_ListaReposicion")
	private int id_ListaReposicion;
	
	@OneToMany(cascade=CascadeType.ALL, fetch=FetchType.EAGER)
	@JoinColumn(name="id_ListaReposicion", referencedColumnName="id_ListaReposicion")
	private List<ItemListaReposicion> items = new ArrayList<>();

	public int getId_ListaReposicion() {
		return id_ListaReposicion;
	}

	public void setId_ListaReposicion(int id_ListaReposicion) {
		this.id_ListaReposicion = id_ListaReposicion;
	}

	public List<ItemListaReposicion> getItems() {
		return items;
	}

	public void setItems(List<ItemListaReposicion> items) {
		this.items = items;
	}

	public static long getSerialversionuid() {
		return serialVersionUID;
	}

	@Override
	public String toString() {
		return "ListaReposicion [id_ListaReposicion=" + id_ListaReposicion
				+ ", items=" + items + "]";
	}

	@Override
	public int hashCode() {
		final int prime = 31;
		int result = 1;
		result = prime * result + id_ListaReposicion;
		result = prime * result + ((items == null) ? 0 : items.hashCode());
		return result;
	}

	@Override
	public boolean equals(Object obj) {
		if (this == obj)
			return true;
		if (obj == null)
			return false;
		if (getClass() != obj.getClass())
			return false;
		ListaReposicion other = (ListaReposicion) obj;
		if (id_ListaReposicion != other.id_ListaReposicion)
			return false;
		if (items == null) {
			if (other.items != null)
				return false;
		} else if (!items.equals(other.items))
			return false;
		return true;
	}
}
